﻿<style src="../../style/statistics.css" scoped></style>
<template>
    <div style="height:100%;">
        <Row>
            <Col span="24" class="col-margin">
            <!--根据需求删除不不要查询条件-->
            填报年份：
            <Select v-model="searchModel.FillInYear" placeholder="全部" :label-in-value="true" @on-change="initReport()" style="width:200px">
                <Option v-for="item in yearList" :value="item.DictValue" :key="item.DictValue">{{ item.DictText }}</Option>
            </Select>
            <!-- <Button icon="ios-search" type="ghost" @click="getPageData()">查询</Button> -->
            <Button icon="ios-download" type="info" @click="ExcelDown()" style="float:right;margin-right:20px" v-show="isCreated&&ReportStatus >1">数据导出</Button>
            <Upload :on-success="handleSuccess" :action="GetPostUrl()" style="float:right;margin-right:20px" v-show="isCreated&&ReportStatus <3">
                <Button type="success" icon="ios-cloud-upload-outline">数据导入</Button>
            </Upload>
            <Button icon="ios-download" type="warning" @click="TmpDown()" style="float:right;margin-right:20px">模板下载</Button>
            </Col>
        </Row>
        <div v-show="isCreated">
        <Row class-name="col-margin">
            <Col span="12" >
            <Button icon="plus" type="primary" :disabled="ReportStatus>2" @click="addItem()">新增</Button>            
            </Col>
            <Col span="12" >
            <div style="float:right;font-size:16px;margin-right:50px;">当前状态：
                <label style="font-size:16px;margin-right:5px;">
                    <span v-if="ReportStatus==0" class="Error">退回重报</span>
                    <span v-else-if="ReportStatus==1" class="NoReport">未填写</span>
                    <span v-else-if="ReportStatus==2" class="AlreadyReport">已填写</span>
                    <span v-else-if="ReportStatus==3" class="UpReport">已上报</span>
                    <span v-else-if="ReportStatus==4" class="Success">审核通过</span>
                </label>
                <span style="float:right;" v-show="ReportStatus==0">[<a @click="ReasonShow=true">未通过原因</a>]</span>
            </div>
            </Col>
        </Row>     
        <Row>
            <Col span="24" class="col-margin">
            <!-- <Table size="large" :height="clientHeight" border  :columns="columnsList" :data="datas.rows" no-data-text='暂无数据...'></Table> -->
                <table class="statisTable" >
                    <thead>
                        <tr>
                            <th rowspan="3" style="width:180px">项目名称</th>
                            <!-- <th rowspan="3">所属地区</th> -->
                            <th rowspan="3">项目来源</th>
                            <th rowspan="3">实施年限（*年*月*日-*年*月*日）</th>
                            <th rowspan="2" colspan="2">项目资金（万元）</th>
                            <th rowspan="2" colspan="3">计划面积产量指标</th>  
                            <th rowspan="3" >操作</th>
                        </tr>
                        <tr>                        
                        </tr>
                        <tr>
                            <th>项目安排</th>
                            <th>配套</th>
                            <th>面积（亩）</th>
                            <th>产量（吨）</th>
                            <th>其他</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="(dataModel,index) in dataList" :key="index" >
                            <td style="text-align:center;width:180px" >                                
                                {{dataModel.ProjectName}}                                
                            </td>
                            <!-- <td style="text-align:center">
                                {{dataModel.AreaName}}
                            </td> -->
                            <td style="text-align:center">                               
                                {{dataModel.ProjectSource}}
                            </td>
                            <td style="text-align:center">                                
                                {{dataModel.Age}}                             
                            </td>
                            <td>                        
                                {{dataModel.ProjectArrange}}                                
                            </td> 
                            <td>                                
                                {{dataModel.ProjectSupport}}                                
                            </td>
                            <td>                                
                                {{dataModel.PlanArea}}                               
                            </td> 
                            <td>                                
                                {{dataModel.PlanYield}}                                   
                            </td>
                            <td style="text-align:center">                                
                                {{dataModel.PlanOther}}                               
                            </td>
                            <td style="text-align: center;">                                
                                <i-button size="small" icon="ios-compose"  style="color:#3399FF"  @click="editModel(dataModel)">
                                    <span style="color:#000;">编辑</span>
                                </i-button>
                                <i-button size="small" icon="ios-trash"  style="color:#FF0000" @click="deletModel(dataModel.Id)">
                                    <span style="color:#000;">删除</span>
                                </i-button>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div class="divButton">
                    <!-- <Button type="primary" @click="save('dataModel')" :disabled="ReportStatus < 3  ? false:true ">保存</Button> -->
                    <Button type="primary" @click="DataUp()" :disabled="ReportStatus ==2  ? false:true ">上报</Button>
                </div>
                <Alert  type="error">
                        填报说明:
                        <p> 1.全省范围内从乡（镇）推广站起，逐级全面统计，由州（市）汇总后上报。</p> 
                        <span slot="desc"></span>
                </Alert>
            </Col>
        </Row>
        </div>
        <div v-show="!isCreated" class="NoCreatedDiv">
            <h1>{{ReportLine}}</h1>
        </div>
        <!-- <Modal v-model="showType" :mask-closable="false" width="1400"  :styles="{top: '20px'}"> 
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">（四）马铃薯项目实施情况统计表</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <Row>
                <Col span="24" class="col-margin">
                    <Button icon="plus" type="primary" :disabled="!pShow" @click="addItem()">新增</Button>            
                </Col>
            </Row>
            <Form ref="DataForm" :model="{dataList}" style="width:100%">
                <div style="overflow-x:auto">
                <table class="reptable" style="width:2900px;margin-bottom:50px;">
                <thead>
                        <tr>
                            <th rowspan="3">项目名称</th>
                            <th rowspan="3">项目来源</th>
                            <th rowspan="3">实施年限（*年*月*日-*年*月*日）</th>
                            <th rowspan="2" colspan="2">项目资金（万元）</th>
                            <th rowspan="2" colspan="3">计划面积产量指标</th>                            
                            <th colspan="14">项目完成情况</th>
                            <th rowspan="2" colspan="5">推广情况</th>                            
                            <th rowspan="3">未完成情况说明</th>
                            <th rowspan="3" class="ivu-table-column-center">操作</th>
                        </tr>
                        <tr>
                            <th colspan="4">总体完成情况</th>
                            <th colspan="7">测产验收情况</th>
                            <th colspan="3">项目增效情况</th>                            
                        </tr>
                        <tr>
                            <th>项目安排</th>
                            <th>配套</th>
                            <th>面积（亩）</th>
                            <th>产量（吨）</th>
                            <th>其他</th>
                            <th>实施地点</th>
                            <th>品种</th>
                            <th>面积（亩）</th>
                            <th>总产（吨）</th>
                            <th>测产面积（亩）</th>
                            <th>测产样本数（点数）</th>
                            <th>测产品种</th>
                            <th>测产平均亩产（公斤/亩）</th>
                            <th>最高亩产（吨）</th>
                            <th>对照品种</th>
                            <th>对照平均亩产（公斤/亩）</th>
                            <th>平均价格（元）</th>
                            <th>平均亩增加投入（元）</th>
                            <th>平均亩增加收益（元）</th>
                            <th>涉及乡镇数（个）</th>
                            <th>涉及村数（个）</th>
                            <th>涉及农户数（户）</th>
                            <th>涉及农业人数（人）</th>
                            <th>带动面积（亩）</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="(dataModel,index) in dataList" :key="index">
                            <td>
                                <Form-item  prop="ProjectName">
                                    <Input v-model="dataModel.ProjectName" ></Input>
                                </Form-item> 
                            </td>
                            <td>
                                <Form-item  prop="ProjectSource">
                                   
                                    <Select v-model="dataModel.ProjectSource" placeholder="请选择" :label-in-value="true" style="width:120px">
                                        <Option v-for="(item,index) in ProjectSourceList" :value="item" :key="index">{{ item }}</Option>
                                    </Select>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="Age">
                                    
                                    <DatePicker v-model="AgeValues[index]" format="yyyy年MM月dd日" 
                                             type="daterange" placement="bottom-end"  
                                             @on-change = "dataModel.Age=($event).join('-')"
                                             placeholder="请选择" style="width: 250px">
                                    </DatePicker>
                                </Form-item> 
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.ProjectArrange'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.ProjectArrange" ></Input>
                                </Form-item>  
                            </td> 
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.ProjectSupport'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.ProjectSupport" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.PlanArea'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.PlanArea" ></Input>
                                </Form-item>  
                            </td> 
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.PlanYield'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.PlanYield" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item >
                                    <Input v-model="dataModel.PlanOther" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item >
                                    <Input v-model="dataModel.ImplePlace" type="textarea" :autosize="true"></Input>
                                </Form-item>  
                            </td> 
                            <td>
                                <Form-item >
                                    
                                    <Select v-model="FVarietys[index]" multiple placeholder="请选择"   style="width:220px">
                                        <Option v-for="item in VarietyList" :value="item.DictText" :key="item.DictValue">{{ item.DictText }}</Option>
                                    </Select>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.FArea'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.FArea" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.FYield'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.FYield" ></Input>
                                </Form-item>  
                            </td> 
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.CCArea'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.CCArea" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.CCSamples'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.CCSamples" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.CCVariety'">
                                    
                                    <Select v-model="CCVarietys[index]" multiple placeholder="请选择"   style="width:220px">
                                        <Option v-for="item in VarietyList" :value="item.DictText" :key="item.DictValue">{{ item.DictText }}</Option>
                                    </Select>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.CCavgMuYield'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.CCavgMuYield" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.CCbestMuYield'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.CCbestMuYield" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item >
                                    
                                    <Select v-model="CCdzVarietys[index]" multiple placeholder="请选择"   style="width:220px">
                                        <Option v-for="item in VarietyList" :value="item.DictText" :key="item.DictValue">{{ item.DictText }}</Option>
                                    </Select>
                                </Form-item> 
                            </td>  
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.CCdzAvgMuYield'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.CCdzAvgMuYield" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.AvgPrice'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.AvgPrice" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.AvgMuInvest'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.AvgMuInvest" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.AvgMuIncome'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.AvgMuIncome" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.Townships'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.Townships" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.Villages'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.Villages" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.Farrmers'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.Farrmers" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.Peoples'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.Peoples" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  :prop="'dataList.' + index + '.DDArea'" :rules="{validator: rule1, trigger: 'blur'}">
                                    <Input v-model="dataModel.DDArea" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item >
                                    <Input v-model="dataModel.UnFinishDescribe" type="textarea" :autosize="true"></Input>
                                </Form-item>   
                            </td>
                            <td style="text-align: center;">                                
                                <i-button type="ghost" size="small" icon="ios-trash-outline" :disabled="!pShow" style="color:#FF0000" @click="delInfo(index)">
                                    <span style="color:#000;">删除</span>
                                </i-button>
                            </td>
                        </tr>
                    </tbody>
                </table>
                </div>
                </Form>                         
            <div style="text-align:right;padding-top:10px">
               <Button type="ghost" v-show="rShow" @click="DataUp()" >上报</Button>
               <Button type="primary" v-show="pShow" @click="save('DataForm')" style="margin-left: 5px">保存</Button>
               <Button type="ghost" @click="showType = false" style="margin-left: 5px">关闭</Button>
          </div>
          <div v-show="ReasonShow" style="margin-top:10px;">
              <div style="background-color:#f9c912;font-size:20px;color:#1C1C1C;padding:10px;">
                  <span>审核不通过原因</span>
                </div>
              <div >
                  <Input v-model="Opinion" type="textarea" readonly :autofocus="true" :rows="4"  ></Input>
              </div>
          </div>
            <div slot="footer" style="padding-bottom:50px">
                <Alert style="margin-top:5px;text-align:left" banner type="error">
                    填报时间：每年1月10日</br>
                    填报说明: 1.全省范围内从乡（镇）起，逐级全面统计，由县级填报经州（市）审核后上报。                                      
                    <span slot="desc">
                    </span>
                </Alert>
            </div>
        </Modal> -->
        <Modal v-model="showType" :mask-closable="false" width="1300" :styles="{top:'10px'}">
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">编辑</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <Form ref="DataForm" :model="detailModel" style="width:100%">
                <table class="statisTable">
                    <thead>
                        <tr>
                            <th rowspan="2" style="width:180px">项目名称</th>
                            <!-- <th rowspan="2">所属地区</th> -->
                            <th rowspan="2">项目来源</th>
                            <th rowspan="2">实施年限（*年*月*日-*年*月*日）</th>
                            <th  colspan="2">项目资金（万元）</th>
                            <th  colspan="3">计划面积产量指标</th> 
                        </tr>
                        <tr>
                            <th>项目安排</th>
                            <th>配套</th>
                            <th>面积（亩）</th>
                            <th>产量（吨）</th>
                            <th>其他</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <!-- <td style="text-align:center;width:180px" >                                
                                {{detailModel.ProjectName}}                                
                            </td>
                            <td style="text-align:center">
                                {{detailModel.AreaName}}
                            </td>
                            <td style="text-align:center">                               
                                {{detailModel.ProjectSource}}
                            </td>
                            <td style="text-align:center">                                
                                {{detailModel.Age}}                             
                            </td>
                            <td>                        
                                {{detailModel.ProjectArrange}}                                
                            </td> 
                            <td>                                
                                {{detailModel.ProjectSupport}}                                
                            </td>
                            <td>                                
                                {{detailModel.PlanArea}}                               
                            </td> 
                            <td>                                
                                {{detailModel.PlanYield}}                                   
                            </td>
                            <td style="text-align:center">                                
                                {{detailModel.PlanOther}}                               
                            </td> -->
                            <td style="width:180px">
                                <Form-item  prop="ProjectName" :rules="{required: true,message:'项目名称不能为空！', trigger: 'blur'}">
                                    <Input v-model="detailModel.ProjectName" ></Input>
                                </Form-item> 
                            </td>
                            <td>
                                <Form-item  prop="ProjectSource" :rules="{required: true,message:'项目来源不能为空！', trigger: 'blur'}">
                                   
                                    <Select v-model="detailModel.ProjectSource" placeholder="请选择" :label-in-value="true" >
                                        <Option v-for="(item,index) in ProjectSourceList" :value="item" :key="index">{{ item }}</Option>
                                    </Select>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="Age">
                                    <DatePicker v-model="AgeValues" format="yyyy年MM月dd日" 
                                             type="daterange" placement="bottom-end"  
                                             @on-change = "detailModel.Age=($event).join('-')"
                                             placeholder="请选择" >
                                    </DatePicker>
                                </Form-item> 
                            </td>
                            <td>
                                <Form-item  prop="ProjectArrange" :rules="commonRule">
                                    <Input  v-model="detailModel.ProjectArrange" ></Input>
                                </Form-item>  
                            </td> 
                            <td>
                                <Form-item  prop="ProjectSupport" :rules="commonRule">
                                    <Input v-model="detailModel.ProjectSupport" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="PlanArea" :rules="commonRule">
                                    <Input v-model="detailModel.PlanArea" ></Input>
                                </Form-item>  
                            </td> 
                            <td>
                                <Form-item  prop="PlanYield" :rules="commonRule">
                                    <Input v-model="detailModel.PlanYield" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item >
                                    <Input type="textarea" v-model="detailModel.PlanOther" :autosize="true"></Input>
                                </Form-item>   
                            </td>
                        </tr>
                        <tr><th style="background-color:white;height:40px"></th></tr>
                        <tr>
                            <th colspan="14">项目完成情况</th>
                        </tr>
                        <tr>
                            <th colspan="4">总体完成情况</th>
                            <th colspan="7">测产验收情况</th>
                            <th colspan="3">项目增效情况</th>                            
                        </tr>
                        <tr>
                            <th>实施地点</th>
                            <th>品种</th>
                            <th>面积（亩）</th>
                            <th>总产（吨）</th>
                            <th>测产面积（亩）</th>
                            <th>测产样本数（点数）</th>
                            <th>测产品种</th>
                            <th>测产平均亩产（公斤/亩）</th>
                            <th>最高亩产（吨）</th>
                            <th>对照品种</th>
                            <th>对照平均亩产（公斤/亩）</th>
                            <th>平均价格（元）</th>
                            <th>平均亩增加投入（元）</th>
                            <th>平均亩增加收益（元）</th>
                        </tr>
                        <tr>
                            <!-- <td style="text-align:center">
                                {{detailModel.ImplePlace}}                                
                            </td> 
                            <td style="text-align:center">
                                {{detailModel.FVariety}}
                            </td>
                            <td>
                                {{detailModel.FArea}}
                            </td>
                            <td>
                                {{detailModel.FYield}}
                            </td> 
                            <td>
                                {{detailModel.CCArea}}                             
                            </td>
                            <td>
                                {{detailModel.CCSamples}}
                            </td>
                            <td>
                                {{detailModel.CCVariety}}
                            </td>
                            <td>
                                {{detailModel.CCavgMuYield}}
                            </td>
                            <td>
                                {{detailModel.CCbestMuYield}}  
                            </td>
                            <td>
                                {{detailModel.CCdzVariety}}
                            </td>  
                            <td>
                                {{detailModel.CCdzAvgMuYield}} 
                            </td>
                            <td>
                                {{detailModel.AvgPrice}}
                            </td>
                            <td>
                                {{detailModel.AvgMuInvest}}
                            </td>
                            <td>
                                {{detailModel.AvgMuIncome}} 
                            </td> -->
                            <td>
                                <Form-item >
                                    <Input v-model="detailModel.ImplePlace" type="textarea" :autosize="true"></Input>
                                </Form-item>  
                            </td> 
                            <td>
                                <Form-item >
                                    <Select v-model="FVarietys" multiple placeholder="请选择"  @on-change = "detailModel.FVariety=($event).join('、')"  >
                                        <Option v-for="item in VarietyList" :value="item.DictText" :key="item.DictValue">{{ item.DictText }}</Option>
                                    </Select>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="FArea" :rules="commonRule">
                                    <Input v-model="detailModel.FArea" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="FYield" :rules="commonRule">
                                    <Input v-model="detailModel.FYield" ></Input>
                                </Form-item>  
                            </td> 
                            <td>
                                <Form-item  prop="CCArea" :rules="commonRule">
                                    <Input v-model="detailModel.CCArea" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="CCSamples" :rules="commonRule">
                                    <Input v-model="detailModel.CCSamples" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="CCVariety">
                                    
                                    <Select v-model="CCVarietys" multiple placeholder="请选择"  @on-change = "detailModel.CCVariety=($event).join('、')">
                                        <Option v-for="item in VarietyList" :value="item.DictText" :key="item.DictValue">{{ item.DictText }}</Option>
                                    </Select>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="CCavgMuYield" :rules="commonRule">
                                    <Input v-model="detailModel.CCavgMuYield" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="CCbestMuYield" :rules="commonRule">
                                    <Input v-model="detailModel.CCbestMuYield" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item >
                                    
                                    <Select v-model="CCdzVarietys" multiple placeholder="请选择" @on-change = "detailModel.CCdzVariety=($event).join('、')" >
                                        <Option v-for="item in VarietyList" :value="item.DictText" :key="item.DictValue">{{ item.DictText }}</Option>
                                    </Select>
                                </Form-item> 
                            </td>  
                            <td>
                                <Form-item  prop="CCdzAvgMuYield" :rules="commonRule">
                                    <Input v-model="detailModel.CCdzAvgMuYield" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="AvgPrice" :rules="commonRule">
                                    <Input v-model="detailModel.AvgPrice" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="AvgMuInvest" :rules="commonRule">
                                    <Input v-model="detailModel.AvgMuInvest" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="AvgMuIncome" :rules="commonRule">
                                    <Input v-model="detailModel.AvgMuIncome" ></Input>
                                </Form-item>   
                            </td>
                        </tr>
                        <tr><th style="background-color:white;"></th></tr>
                        <tr>
                            <th colspan="5">推广情况</th>
                        </tr>
                        <tr>
                            <th>涉及乡镇数（个）</th>
                            <th>涉及村数（个）</th>
                            <th>涉及农户数（户）</th>
                            <th>涉及农业人数（人）</th>
                            <th>带动面积（亩）</th>
                        </tr>
                        <tr>
                            <!-- <td>
                                {{detailModel.Townships}}
                            </td>
                            <td>
                                {{detailModel.Villages}}  
                            </td>
                            <td>
                                {{detailModel.Farrmers}}  
                            </td>
                            <td>
                                {{detailModel.Peoples}}
                            </td>
                            <td>
                                {{detailModel.DDArea}}
                            </td> -->
                            <td>
                                <Form-item  prop="Townships" :rules="commonRule">
                                    <Input v-model="detailModel.Townships" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="Villages" :rules="commonRule">
                                    <Input v-model="detailModel.Villages" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="Farrmers" :rules="commonRule">
                                    <Input v-model="detailModel.Farrmers" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="Peoples" :rules="commonRule">
                                    <Input v-model="detailModel.Peoples" ></Input>
                                </Form-item>   
                            </td>
                            <td>
                                <Form-item  prop="DDArea" :rules="commonRule">
                                    <Input v-model="detailModel.DDArea" ></Input>
                                </Form-item>   
                            </td>
                        </tr>
                        <tr><th style="background-color:white;"></th></tr>
                        <tr>
                            <th style="width:20%;">未完成情况说明</th>
                            <td style="text-align:center;">
                               <Form-item >
                                    <Input v-model="detailModel.UnFinishDescribe" type="textarea" :autosize="{minRows:4,maxRows:8}"></Input>
                                </Form-item>   
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div class="divButton">
                    <Button type="primary" @click="saveModel" >保存</Button>
                    <Button type="ghost" @click="editCancel" >取消</Button>
                </div>
            </Form>
            <div slot="footer">
            </div>
        </Modal>
    </div>
</template>
<script>
export default {
    data() {
        const validateData = (rule, value, callback) => {
            var temp = /^[0-9]\d*(\.\d+)?$/;
            if (value||value==0) {
                if (temp.test(value) == false) {
                    callback(new Error("必须是数字！"));
                } else {
                    callback();
                }
            } else {
                callback(new Error("不能为空！"));
            }
        };
        return {
            isCreated:false,//是否需要显示报表
            ReportLine:'',//不显示报表时所显示文字
            tt:[],
            ReasonShow:false,
            Opinion:'',
            showType: false,//编辑框弹出状态
            rShow: false, //是否显示上报按钮
            pShow: false, //是否显示保存按钮
            yearList: this.GetGroupDict("ReportYear"),
            ReportId: "",
            ReportStatus: "",            
            dataList: [],
            datas:{},
            FVarietys:new Array(),//二维数组，用于保存总体完成情况品种多选model数组
            CCVarietys:new Array(),//二维数组，用于保存测产品种多选model数组
            CCdzVarietys:new Array(),//二维数组，用于保存测产对照品种多选model数组
            AgeValues:new Array(),//二维数组
            VarietyList:this.GetGroupDict("PotatoVariety"),
            rule1:validateData, //验证是否是数字
            ProjectSourceList:["部级","省级","省级以下"],     
            commonRule:{validator: validateData, trigger: 'blur'},       
            detailModel: {//编辑模型
                Id: 0,
                ReportId:'', 
                ProjectName:'', 
                ProjectSource:'', 
                Age:'', 
                ProjectArrange:'', 
                ProjectSupport:'', 
                PlanArea:'', 
                PlanYield:'', 
                PlanOther:'', 
                ImplePlace:'', 
                FVariety:'', 
                FArea:'', 
                FYield:'', 
                CCArea:'', 
                CCSamples:'', 
                CCVariety:'', 
                CCavgMuYield:'', 
                CCbestMuYield:'', 
                CCdzVariety:'', 
                CCdzAvgMuYield:'', 
                AvgPrice:'', 
                AvgMuInvest:'', 
                AvgMuIncome:'', 
                Townships:'', 
                Villages:'', 
                Farrmers:'', 
                Peoples:'', 
                DDArea:'', 
                unFinishDescribe:'', 
            },
            clientHeight: window.innerHeight - 175,//表格默认高度
            //查询模型：根据需求删除不不要查询条件
            searchModel: {                
                AreaCode: this.GetlocaStorage("potUserinfo").AreaCode,
                ReportCode:'PotProject',
                FillInYear:new Date().getFullYear()+'',
                PageNumber: 1, PageSize: 20
            },
            columnsList: [//表头对象
                {
                    title: '报表名称',
                    key: 'ReportCodeName',
                    ellipsis: true,                    
                },
                {
                    title: '归属地区',
                    key: 'AreaCodeName',
                    width: 120
                },
                {
                    title: '填报年度',
                    key: 'FillInYearName',
                    width: 120
                },
                // {
                //     title: '填报周期',
                //     key: 'TimesTypeName',
                //     width: 120
                // },
                // {
                //     title: '周期详情',
                //     key: 'TimesCycleName',
                //     width: 120
                // },
                {
                    title: "报表状态",
                    key: "StatusName",
                    width: 120,
                    render: (h, params) => {
                        switch (params.row.Status * 1) {
                            case 0: //审核未通过
                                return h('span', { class: { Error: true } }, params.row.StatusName);
                            case 1: //未填报
                                return h('span', { class: { NoReport: true } }, params.row.StatusName);
                            case 2: //已填报
                                return h('span', { class: { AlreadyReport: true } }, params.row.StatusName);
                            case 3: //已上报
                                return h('span', { class: { UpReport: true } }, params.row.StatusName);
                            case 4: //审核通过
                                return h('span', { class: { Success: true } }, params.row.StatusName);
                            case 5: //锁定
                                return h('span', { class: { error: true } }, params.row.StatusName);
                            default:
                                return h('span', { class: { Default: true } }, params.row.StatusName);
                        }
                    }
                },
                {
                    title: '添加时间',
                    key: 'StrAddTime',
                    ellipsis: true
                },
                {
                    title: '操作',
                    key: 'action',
                    width: 250,
                    align: 'center',
                    render: (h, params) => {
                        return h('div', [
                            h('Upload', {
                                props: {
                                    //导入成功后响应窗口
                                    onSuccess: (res) => { this.handleSuccess(res) },
                                    action: this.GetPostUrl(params.row.Id),
                                    size: 'small'
                                },
                                style: {
                                    float: 'left', marginTop: '10px'
                                }
                            }, [h('Button', {
                                class: { searchButton: true },
                                props: {
                                    type: 'success', size: 'small', icon: 'ios-cloud-upload-outline'
                                },
                                attrs: {
                                    disabled: params.row.Status > 2 ? true : false
                                },
                                style: {
                                    marginRight: '5px'
                                }
                            }, '导入')]),
                            // h('Button', {
                            //     class: { ieditColor: true },
                            //     props: {
                            //         type: 'ghost', size: 'small', icon: 'ios-compose'
                            //     },
                            //     style: { marginRight: '5px', marginTop: '10px' },
                            //     on: {
                            //         click: () => { this.See(params.row.Id,params.row.TimesCycleName); }
                            //     }
                            // }, '查看'),
                            h('Button', {
                                // class: { ieditColor: true },
                                props: {
                                    type: 'primary', size: 'small', icon: 'ios-compose'
                                },
                                attrs: {
                                    //disabled: params.row.Status > 2 ? true : false
                                },
                                style: { marginRight: '5px', marginTop: '10px' },
                                on: {
                                    click: () => { 
                                        if (params.row.Status == 2) {
                                            this.rShow = true;
                                            this.pShow = true;
                                        } else if (params.row.Status <= 1) {
                                            this.pShow = true;
                                            if(params.row.Status==0){
                                                this.ReasonShow = true;
                                                this.Opinion = params.row.Opinion;
                                            }
                                        }
                                        
                                        this.editInfo(params.row.Id);
                                    }
                                }
                            }, params.row.Status <= 2 ? "填报" : "查看"),
                            // h('Button', {
                            //     class: { ieditColor: true },
                            //     props: {
                            //         type: 'ghost', size: 'small', icon: 'arrow-up-a'
                            //     },
                            //     attrs: {
                            //         disabled: params.row.Status != 2 ? true : false
                            //     },
                            //     style: { marginRight: '5px', marginTop: '10px' },
                            //     on: {
                            //         click: () => { this.DataUp(params.row.Id, '3', ''); }
                            //     }
                            // }, '上报'),
                            h('Button', {
                                // class: { ieditColor: true },
                                props: {
                                    type: 'info', size: 'small', icon: 'ios-compose'
                                },
                                attrs: {
                                     disabled: params.row.Status < 2 ? true : false
                                },
                                style: { marginRight: '5px', marginTop: '10px' },
                                on: {
                                    click: () => { this.ExcelDown(params.row.Id,params.row.AreaCodeName); }
                                }
                            }, '导出')
                        ]);
                    }
                }]

        }
    },
    mounted() {
        //table高度计算方法
        const that = this;
        window.onresize = () => {
            return (() => {
                that.clientHeight = window.innerHeight - 175;
            })()
        };
    },
    methods: {                                                
        getPageData() {
            var self = this;
            // self.$http.post('Report/PostPageList', this.searchModel).then(function (res) {
            //     if (res.data.status === 1) {
            //         self.datas = res.data;
            //     }
            //     else {
            //         self.$Modal.error({ title: '提示信息', content: res.data.message });
            //     }
            // });
            this.$http.get('PotProject/GetFillInModel', {params:{AreaCode:this.searchModel.AreaCode,FillInYear:this.searchModel.FillInYear}}).then(function (res) {
                    if (res.data.status == 1) {
                        self.dataList = res.data.model.list;
                        self.ReportStatus = res.data.model.ReportStatus;
                        self.ReportId = res.data.model.ReportId;
                        self.Opinion = res.data.model.Opinion;
                        self.isCreated = true;
                    }
                    else {
                        self.isCreated = false;
                        self.ReportLine = '报表未生成！'
                        self.$Modal.error({ title: '提示信息', content: res.data.message });
                    }
                });
        },
        //编辑获取对象传入id
        editInfo(id) {//编辑
            var self = this;
            this.showType=true;
            this.ReportId = id;
            this.$http.get("PotProject", { params: { ReportId: id } }).then(//获取数据编辑项的值
                function (res) {
                    if (res.data.status == 1) {
                        self.dataList = res.data.model; 
                        if(self.dataList.length>0){
                            for(var i=0; i<self.dataList.length; i++){
                                var tItem = self.dataList[i];
                                self.FVarietys[i] = new Array();
                                self.CCVarietys[i] = new Array();
                                self.CCdzVarietys[i] = new Array();
                                self.AgeValues[i] = new Array();
                                if(tItem.FVariety){
                                self.FVarietys[i] = tItem.FVariety.split("、");
                                }
                                if(tItem.CCVariety){
                                self.CCVarietys[i] = tItem.CCVariety.split("、");
                                }
                                if(tItem.CCdzVariety){
                                self.CCdzVarietys[i] = tItem.CCdzVariety.split("、");
                                }
                                if(tItem.Age){
                                    self.AgeValues[i] = tItem.Age.split("-");
                                }
                            }                         
                        }                          
                    }
                    else {
                        self.$Modal.error({ title: "提示信息", content: "数据加载失败!!!" });
                    }
                }
            );
        },
        //新增
        addItem() {
            let model = {        
                Id: '',
                ReportId:'', 
                ProjectName:'', 
                ProjectSource:'', 
                Age:'', 
                ProjectArrange:'', 
                ProjectSupport:'', 
                PlanArea:'', 
                PlanYield:'', 
                PlanOther:'', 
                ImplePlace:'', 
                FVariety:'', 
                FArea:'', 
                FYield:'', 
                CCArea:'', 
                CCSamples:'', 
                CCVariety:'', 
                CCavgMuYield:'', 
                CCbestMuYield:'', 
                CCdzVariety:'', 
                CCdzAvgMuYield:'', 
                AvgPrice:'', 
                AvgMuInvest:'', 
                AvgMuIncome:'', 
                Townships:'', 
                Villages:'', 
                Farrmers:'', 
                Peoples:'', 
                DDArea:'', 
                unFinishDescribe:'', 
            };
             var entity = new Object();
            entity = model;
            entity.ReportId = this.ReportId;
            //this.dataList.push(entity);
            this.detailModel = entity;
            this.AgeValues = [];
            this.CCdzVarietys = [];
            this.CCVarietys = [];
            this.FVarietys = [];
            this.showType = true;
        },
        //删除对象
        delInfo(index) {
            var self = this;
            this.dataList.splice(index, 1);
        },
        //保存方法
        save(modelname) {
            var self = this;
            this.$refs[modelname].validate((valid) => {
                if (valid) {
                    for(var i=0; i<this.dataList.length; i++){
                        let tItem1 = this.FVarietys[i];
                        let tItem2 = this.CCVarietys[i];
                        let tItem3 = this.CCdzVarietys[i];
                        
                        if(tItem1){
                            this.dataList[i].FVariety = tItem1.join("、");
                        }
                        if(tItem2){
                            this.dataList[i].CCVariety = tItem2.join("、");
                        }
                        if(tItem3){
                            this.dataList[i].CCdzVariety = tItem3.join("、");
                        }
                    }
                    this.$http.post('PotProject', this.dataList).then(
                        function (res) {
                            if (res.data.status == 1) {
                                    self.getPageData();//读取分页数据
                                    self.rShow = true;
                                    self.$Notice.success({ title: '保存成功！', desc: false });
                                }
                                else {
                                    self.$Modal.warning({ title: "提示信息", content: "添加失败,请与管理员联系!" });
                                }
                    });
                     
                }
            });
        },
        //数据上报
        DataUp() {
            var self = this;
            let model = new Object();
            model.Id = this.ReportId;
            model.Status = 3;
            model.Opinion = '';
            self.$Modal.confirm({
                title: '提示信息',
                content: '<p>数据上报后，不能再更改，是否继续上报？</p>',
                onOk: () => {
                    this.$http.post("Report/PostUpStatus", model).then(
                        function (res) {
                            if (res.data.status == 1) {
                                self.showType = false;
                                self.$Notice.success({ title: '数据上报成功！', desc: false });
                                self.getPageData();
                            }
                            else {
                                self.$Modal.error({ title: "提示信息", content: "数据上报失败!" });
                            }
                        }
                    );
                }
            });
        },
        //模板下载
        TmpDown:function(){
            window.open(this.$http.defaults.baseURL + "Report/GetTemplateData?ReportCode=" + this.searchModel.ReportCode);
        },
        //导入
        GetPostUrl() {
            var url = this.$http.defaults.baseURL + "PotProject/PostImportData?ReportId=" + this.ReportId;
            return url;
        },
        //导入成功反馈事件
        handleSuccess(res) {
            var self = this;
            self.getPageData();
            if(res.status == -1){
                self.$Modal.warning({
                    title: "提示信息",
                    content: res.message
                });
            }else{
                self.$Notice.success({
                    title: '数据导入成功！',
                    desc: false
                });
            }            
        },
        //导出
        ExcelDown: function () {           
            window.open(this.$http.defaults.baseURL + "PotProject/GetExcelData?ReportId=" + this.ReportId + "&&FillInYear=" + this.searchModel.FillInYear + "&&AreaCode=" + this.searchModel.AreaCode);
        },
        editModel(Model){
            this.detailModel = Model;
             if(Model.FVariety){
                this.FVarietys = Model.FVariety.split("、");
            }
            if(Model.CCVariety){
                this.CCVarietys = Model.CCVariety.split("、");
            }
            if(Model.CCdzVariety){
                this.CCdzVarietys = Model.CCdzVariety.split("、");
            }
            if(Model.Age){
                this.AgeValues = Model.Age.split("-");
            }
            this.showType = true;
        },
        deletModel(Id){
            var self = this;
            this.$Modal.confirm({
                title: '提示信息',
                content: '<p>是否确认删除？</p>',
                onOk: () => {
                    self.$http.delete('PotProject',{params:{id:Id}}).then(function(res){
                        if (res.data.status == 1) {
                            self.$Notice.success({ title: '删除成功！', desc: false });
                            self.getPageData();
                        }
                        else {
                            self.$Modal.error({ title: "提示信息", content: "删除失败!" });
                        }
                    });
                }
            });
        },
        saveModel(){
            var self = this;
            this.$refs['DataForm'].validate((valid) => {
                if (valid) {
                    if(!this.detailModel.Id){
                        this.$http.post('PotProject/PostFillInModel',this.detailModel).then(function(res){
                            if (res.data.status == 1) {
                                self.$Notice.success({ title: '保存成功！', desc: false });
                                self.getPageData();
                                self.showType = false;
                            }
                            else {
                                self.$Modal.error({ title: "提示信息", content: res.data.message });
                            }
                        });
                    }
                    else{
                        this.$http.put('PotProject',this.detailModel).then(function(res){
                            if (res.data.status == 1) {
                                self.$Notice.success({ title: '保存成功！', desc: false });
                                self.getPageData();
                                self.showType = false;
                            }
                            else {
                                self.$Modal.error({ title: "提示信息", content: res.data.message });
                            }
                        });
                    }
                    
                }
                else{
                    self.$Modal.error({ title: "提示信息", content: '无法保存，请检查是否有未填项！' });
                }
            })
            
        },
        editCancel(){
            this.showType = false;
        },
        initReport(){
            var today = new Date();
            let currentYear = today.getFullYear();
            let currentMonth = today.getMonth() + 1;
            if(this.searchModel.FillInYear*1 == currentYear &&currentMonth==12){
               this.getPageData();
            }
            else if(this.searchModel.FillInYear*1 == currentYear-1 && currentMonth >= 1 && currentMonth <= 5){
                this.getPageData();
            }
            else if(this.searchModel.FillInYear < currentYear){
                this.getPageData();
            }
            else {
                this.isCreated = false;
                this.ReportLine = '不在填报时间内！';
            }
        }
    },
    //创建Vue页面方法
    created: function () {
        //创业Vue前调用获取this.datas: {},//table数据对象
        this.initReport();
    },
    watch: {
        //需要监听的在此处新增监听对象
    }
}
</script>
<style scoped>
.ivu-form-item{
    margin-bottom: 0 !important;
}
</style>
